//-------------------------------------------------------------------
//	Copyright (c) 2010-2012 Zhirnov Andrey
//	This file is part of the "UXGEN" project.
//	See copyright notice in "Engine.h".
//-------------------------------------------------------------------

#ifndef _UX_SCENE_TYPES_H
#define _UX_SCENE_TYPES_H

#include "SceneBase.h"

namespace Engine
{
namespace Scene
{


	//
	// Key Bind
	//

	template <typename E>
	struct TKeyBind
	{
		E				eBind;
		e_key::type		eKey1,
						eKey2;
		///
		TKeyBind():
			eBind(E(0)), eKey1(e_key::_UNKNOWN), eKey2(e_key::_UNKNOWN)
		{}

		explicit
		TKeyBind(E bind, e_key::type key1, e_key::type key2 = e_key::_UNKNOWN):
			eBind(bind), eKey1(key1), eKey2(key2)
		{}
			
		template <bool bClick>
		bool CheckState() const;
		
		template <>
		bool CheckState<true>() const
		{
			return	GLOBAL::INPUT()->IsKeyClick( eKey1 ) ||
					GLOBAL::INPUT()->IsKeyClick( eKey2 );
		}

		template <>
		bool CheckState<false>() const
		{
			return	GLOBAL::INPUT()->IsKey( eKey1 ) ||
					GLOBAL::INPUT()->IsKey( eKey2 );
		}

		bool IsValid() const
		{
			return ( eBind != e_key_bind::UNKNOWN && (
					 eKey1 != e_key::_UNKNOWN || eKey2 != e_key::_UNKNOWN ) );
		}

		void Repair()
		{
			if ( eKey1 == e_key::_UNKNOWN &&
				 eKey2 != e_key::_UNKNOWN )
			{
				_swap( eKey1, eKey2 );
			}
		}
	};

//-------------------------------------------------------------------

}	// Scene
}	// Engine

#endif	// _UX_SCENE_TYPES_H